<?php

namespace App\Observers;

use App\Models\User\WechatOfficialUser;
use Illuminate\Support\Facades\Cache;

class WechatOfficialUserObserver
{
    public function saved(WechatOfficialUser $user)
    {
        $cache_key = "OfficialUser:oid:{$user->getOpenId()}";
        Cache::put($cache_key, $user->refresh(), config('trip.ttl.day'));
    }

    public function updated(WechatOfficialUser $user)
    {
        $cache_key = "OfficialUser:oid:{$user->getOpenId()}";
        Cache::put($cache_key, $user->refresh(), config('trip.ttl.day'));
    }
}
